<!DOCTYPE html>
<html lang="en">
<head>
    <title>充值报表</title>
    {% include 'admin/common/header.html' %}
    <link rel="stylesheet" href="{{ url_for('static', filename='admin/admin/css/other/user.css') }}"/>
    <style type="text/css">
<!--      {# 设置table每一行的height #}-->
      .layui-table-cell {
           height: auto;
           line-height: 50px;
      }
     </style>
</head>
<body class="pear-container">
{# 表格 #}
<div class="user-main user-collasped">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="order-table" lay-filter="order-table"></table>
        </div>
    </div>
</div>
</body>

{% include 'admin/common/footer.html' %}

<script>
  layui.use(['table', 'form', 'jquery', 'laydate'], function () {
    let table = layui.table
    let form = layui.form
    let $ = layui.jquery
    let laydate = layui.laydate;

    let MODULE_PATH = '/admin/report/'

    // 表格数据
    let cols = [
      [
        { title: '序号', type: 'numbers', align: 'center' },
        { title: '统计类型', field: 'statistics_type', align: 'center',
            templet: function (data) {
                let type = data.statistics_type;
                let color, type_name;
                if (type == 0) {
                    color = 'red';
                    type_name = '全部小说';
                } else if (type == 1) {
                    color = 'blue';
                    type_name = '男频小说';
                } else if (type == 2) {
                    color = 'green';
                    type_name = '女频小说';
                } else if (type == 3) {
                    type_name = '男频小说';
                } else if (type == 4) {
                    type_name = '女频小说';
                }
                return `<p style="color: ${color};">${type_name}</p>`;
            }
        },
        { title: '创作方向', field: 'work_direction', align: 'center' },
        { title: '分类', field: 'cat_name', align: 'center' },
        { title: '小说总本数', field: 'total_book_count', align: 'center' },
        { title: '小说总字数', field: 'total_word_count', align: 'center' },
        { title: '小说总访问量', field: 'total_visit_count', align: 'center' },
        { title: '小说总评论量', field: 'total_comment_count', align: 'center' },
      ]
    ]

    // 渲染表格数据
    table.render({
      elem: '#order-table',
      url: MODULE_PATH + 'book_statistics/data',
      page: true,
      cols: cols,
      skin: 'line',
      height: 'full-148',
      toolbar: '#order-toolbar', /*工具栏*/
      text: { none: '暂无数据' },
      defaultToolbar: [{ layEvent: 'refresh', icon: 'layui-icon-refresh' }, 'filter', 'print', 'exports'] /*默认工具栏*/
    })

    table.on('toolbar(order-table)', function (obj) {
      if (obj.event === 'refresh') {
        window.refresh()
      }
    })

    form.on('submit(order-query)', function (data) {
      window.refresh(data.field)
      return false
    })

    window.refresh = function (param) {
      table.reload('order-table', { where: param })
    }


  })
</script>
</html>